package java_math;
/**
 * java.math��һ������ֻҪ�ṩ����ִ�����⾫�������㷨 (BigInteger) �����⾫��С���㷨 (BigDecimal) ���࣬
 * һ������רҵ����ѧ���㣬
 * ��java.lang.Math��һ���࣬���������������ֲ�������ָ����������ƽ���������Ǻ���
 * @author cb
 *
 */
public class MathDemo {  
    public static void main(String args[]){  
        /** 
         * abs������ֵ 
         */  
        System.out.println(Math.abs(-10.4));    //10.4  --
        System.out.println(Math.abs(10.1));     //10.1  
          
        /** 
         * ceil�컨������˼�����Ƿ��ش���ֵ��ע��һЩ����ֵ 
         */  
        System.out.println(Math.ceil(-10.1));   //-10.0  
        System.out.println(Math.ceil(10.7));    //11.0  
        System.out.println(Math.ceil(-0.7));    //-0.0  
        System.out.println(Math.ceil(0.0));     //0.0  
        System.out.println(Math.ceil(-0.0));    //-0.0  
          
        /** 
         * floor�ذ�����˼�����Ƿ���С��ֵ 
         */  
        System.out.println(Math.floor(-10.1));  //-11.0  
        System.out.println(Math.floor(10.7));   //10.0  
        System.out.println(Math.floor(-0.7));   //-1.0  
        System.out.println(Math.floor(0.0));    //0.0  
        System.out.println(Math.floor(-0.0));   //-0.0  
          
        /** 
         * max �����з��ش���ֵ,min�����෴���Ͳ������� 
         */  
        System.out.println(Math.max(-10.1, -10));   //-10.0  
        System.out.println(Math.max(10.7, 10));     //10.7  
        System.out.println(Math.max(0.0, -0.0));    //0.0  
          
        /** 
         * random ȡ��һ�����ڻ��ߵ���0.0С�ڲ�����1.0�������� 
         */  
        System.out.println(Math.random());  //0.08417657924317234  
        System.out.println(Math.random());  //0.43527904004403717  
          
        /** 
         * rint �������룬����doubleֵ 
         * ע��.5��ʱ����ȡż�� 
         */  
        System.out.println(Math.rint(10.1));    //10.0  
        System.out.println(Math.rint(10.7));    //11.0  
        System.out.println(Math.rint(11.5));    //12.0  
        System.out.println(Math.rint(10.5));    //10.0  
        System.out.println(Math.rint(10.51));   //11.0  
        System.out.println(Math.rint(-10.5));   //-10.0  
        System.out.println(Math.rint(-11.5));   //-12.0  
        System.out.println(Math.rint(-10.51));  //-11.0  
        System.out.println(Math.rint(-10.6));   //-11.0  
        System.out.println(Math.rint(-10.2));   //-10.0  
          
        /** 
         * round �������룬floatʱ����intֵ��doubleʱ����longֵ 
         */  
        System.out.println(Math.round(10.1));   //10  
        System.out.println(Math.round(10.7));   //11  
        System.out.println(Math.round(10.5));   //11  
        System.out.println(Math.round(10.51));  //11  
        System.out.println(Math.round(-10.5));  //-10  
        System.out.println(Math.round(-10.51)); //-11  
        System.out.println(Math.round(-10.6));  //-11  
        System.out.println(Math.round(-10.2));  //-10  
        
        /*----��������������---------------java.lang.math-------------------------------*/
        //������ת���Ƕ�
        System.out.println("Math.toDegrees(1.57)��" + Math.toDegrees(1.57));
        //���Ƕ�ת��Ϊ����
        System.out.println("Math.toRadians(90)��" + Math.toRadians(90));
        //���㷴���ң����صĽǶȷ�Χ��0.0��pi֮��
        System.out.println("Math.acos(0.3)��" + Math.acos(0.3));
        //���㷴���ң����صĽǶȷ�Χ�� -pi/2 �� pi/2 ֮��
        System.out.println("Math.asin(0.8)��" + Math.asin(0.8));
        //���㷴���У����صĽǶȷ�Χ�� -pi/2 �� pi/2 ֮��
        System.out.println("Math.atan(2.3)��" + Math.atan(2.3));
        //������������
        System.out.println("Math.cos(1.57)��" + Math.cos(1.57));
        //����ֵ��˫������
        System.out.println("Math.cosh(1.2)��" + Math.cosh(1.2));
        //��������
        System.out.println("Math.sin(1.57)��" + Math.sin(1.57));
        //����˫������
        System.out.println("Math.sinh(1.2)��" + Math.sinh(1.2));
        //������������
        System.out.println("Math.tan(0.8)��" + Math.tan(0.8));
        //����˫������
        System.out.println("Math.tanh(2.1)��" + Math.tanh(2.1));
        //����������(x,y)ת���ɼ�����(r,thet)���������ý�theta
        System.out.println("Math.atan2(0.1,0.2)��" + Math.atan2(0.1,0.2));

        /*----������ȡ������----*/
        //ȡ��������С��Ŀ��������������
        System.out.println("Math.floor(-1.2)��" + Math.floor(-1.2));
        //ȡ�������ش���Ŀ��������С����
        System.out.println("Math.ceil(1.2)��" + Math.ceil(1.2));
        //��������ȡ��
        System.out.println("Math.round(2.3)��" + Math.round(2.3));
    }  
}  